import React, { useEffect, useState } from 'react';
import request from 'umi-request';
import { Table, Tag, Space } from 'antd';
export default function list() {
  const [data, setData] = useState([]);
  const columns = [
    {
      title: '姓名',
      dataIndex: 'username',
      key: 'username',
      render: (text: any) => <a>{text}</a>,
    },
    {
      title: '年龄',
      dataIndex: 'age',
      key: 'age',
      defaultSortOrder: 'descend',
      sorter: (a: any, b: any) => a.age - b.age,
    },
    {
      title: '创建日期',
      dataIndex: 'date',
      key: 'date',
    },
    {
      title: '籍贯',
      dataIndex: 'adderss',
      key: 'adderss',
    },
  ];

  useEffect(() => {
    request
      .get('/api/user/list')
      .then(res => {
        setData(res.list);
      })
      .catch(error => {
        console.log(error);
      });
  }, []);

  return <Table columns={columns} dataSource={data} />;
}
